package com.tony.study.designMode.DM2_抽象工厂;

import com.tony.study.designMode.DM2_抽象工厂.DM2.ProduceKeyBoard;
import com.tony.study.designMode.DM2_抽象工厂.DM2.ProduceMouse;
import com.tony.study.designMode.DM2_抽象工厂.Factory.Lenovo1Factory;
import com.tony.study.designMode.DM2_抽象工厂.Factory.Lenovo2Factory;

/**
 * Created with IntelliJ IDEA.
 *
 * @Title: AFactoryTest
 * @Auther: 皮蛋布丁
 * @Date: 2021/11/01/14:34
 * @Description: 抽象工厂测试（具体工厂类实现不同电脑组件的生产）
 * 好处：横向扩展容易，若需要增加一个电脑型号，只需创建对应的工厂实现抽象工厂即可
 * 缺点：纵向扩展难，若需要增加显示器的生产接口，那么每个地方都需要改动
 */
public class AFactoryTest {

    public static void main(String[] args) {
        //用户购买联想(雷柏的鼠标和键盘),便找到对应01生产的电脑组装,工厂进行生产
        Lenovo1Factory lenovo1Factory = new Lenovo1Factory();
        ProduceKeyBoard keyBoard1 = lenovo1Factory.createKeyBoard();
        keyBoard1.productKeyBord("M550","黑色");
        ProduceMouse mouse1 = lenovo1Factory.createMouse();
        mouse1.productMouse("M590","有线");

        System.out.println("====================分割线====================");

        //用户购买联想(罗技的鼠标和键盘),便找到对应02生产的电脑组装,工厂进行生产
        Lenovo2Factory lenovo2Factory = new Lenovo2Factory();
        ProduceKeyBoard keyBoard2 = lenovo2Factory.createKeyBoard();
        keyBoard2.productKeyBord("M550","白色");
        ProduceMouse mouse2 = lenovo2Factory.createMouse();
        mouse2.productMouse("M590","无线");
    }
}
